package com.example.ArticleService;

import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class ArticleServiceTest {
    private ArticleService articleService;

    @BeforeEach
    public void setUp() {
        articleService = new ArticleService();
    }

    @Test
    public void testPublishArticleSuccess() {
        assertTrue(articleService.publishArticle("标题", "内容"));
    }

    @Test
    public void testPublishArticleWithNullTitle() {
        Exception exception = assertThrows(IllegalArgumentException.class, () -> {
            articleService.publishArticle(null, "内容");
        });
        assertEquals("标题和内容不能为空", exception.getMessage());
    }
}
